package com.sskj.ws.config;

import com.sskj.common.constant.RabbitMQConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class RabbitMQConfig {

    @Bean
    public DirectExchange deviceExchange() {
        return new DirectExchange(RabbitMQConstant.DEVICE_EXCHANGE, true, false);
    }

    @Bean
    public Queue devicePropsQueue() {
        return new Queue(RabbitMQConstant.DEVICE_PROPS_QUEUE, true);
    }

    @Bean
    public Binding devicePropsBinding() {
        return BindingBuilder.bind(devicePropsQueue()).to(deviceExchange()).with(RabbitMQConstant.DEVICE_PROPS_ROUTEING_KEY);
    }
}
